'use strict';
module.exports = app => {
  app.beforeStart(async () => {
    let requestURL = '';
    try {
      if (process.env.NODE_ENV === 'development') {
        requestURL = 'http://112.112.149.28:81/front/menu/tree';
      } else if (process.env.NODE_ENV === 'production') {
        requestURL = 'http://10.1.103.105:8888/menu/tree';
      }

      const menus = await app.curl(requestURL, {
        method: 'GET',
        dataType: 'json',
      });
      app.menus = menus.data.data;
    } catch (e) {
      app.menus = [];
    }
  });
};
